﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using v1_SweetGeeks.Model;

namespace v1_SweetGeeks.Controller
{
    public unsafe class controller
    {
        bool locked = false;

        public void InitializeModel()
        {
            do
            {
                if(!locked)
                {
                    locked = true;
                    CustomerCollection.LoadAllData();
                    locked = false;
                }
            }while(locked);
        }

        public string GetProductName()
        {
            string result = "";

            do
            {
                if(!locked)
                {
                    locked = true;
                    result = CustomerCollection.GetProductName();
                    locked = false;
                }
            }while(locked);

            return result;
        }
        
        public double* BindToExpectedMonth()
        {
            double* result = null;

            do
            {
                if(!locked)
                {
                    locked = true;
                    result = CustomerCollection.BindToExpectedProfit();
                    locked = false;
                }
            }while(locked);
            
            return result;
        }

        public double* BindToCurrentMonth()
        {
            double* result = null;

            do
            {
                if(!locked)
                {
                    locked = true;
                    result = CustomerCollection.BindToCurrentProfit();
                    locked = false;
                }
            }while(locked);
            
            return result;
        }

        public double* BindToLastMonth()
        {
            double* result = null;

            do
            {
                if(!locked)
                {
                    locked = true;
                    result = CustomerCollection.BindToLastProfit();
                    locked = false;
                }
            }while(locked);
            
            return result;
        }
        
        public void IterateProductIterator()
        {
            do
            {
                if(!locked)
                {
                    CustomerCollection.IterateProductIterator();
                }
            }while(locked);
        }

        public double* BindToExpectedProductProfit()
        {
            double* result = null;

            do
            {
                if(!locked)
                {
                    locked = true;
                    result = CustomerCollection.BindToExpectedProductProfit();
                    locked = false;
                }
            }while(locked);
            
            return result;
        }

        public double* BindToCurrentProductProfit()
        {
            double* result = null;

            do
            {
                if(!locked)
                {
                    locked = true;
                    result = CustomerCollection.BindToCurrentProductProfit();
                    locked = false;
                }
            }while(locked);
            
            return result;
        }

        public double* BindToLastProductProfit()
        {
            double* result = null;

            do
            {
                if(!locked)
                {
                    locked = true;
                    result = CustomerCollection.BindToLastProductProfit();
                    locked = false;
                }
            }while(locked);
            
            return result;
        }

        public uint* BindToProductState()
        {
            uint* result = null;

            do
            {
                if(!locked)
                {
                    locked = true;
                    result = CustomerCollection.BindToProductState();
                    locked = false;
                }
            }while(locked);
            
            return result;
        }

        public int* BindToProductViews()
        {
            int* result = null;

            do
            {
                if(!locked)
                {
                    locked = true;
                    result = CustomerCollection.BindToProductViews();
                    locked = false;
                }
            }while(locked);
            
            return result;
        }
    }
}
